﻿using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.IO;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using System.Reflection;
using log4net;


namespace AnyOffice.general.ipanel
{
    public partial class ajax_state : Page
    {
        private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
       
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Response.AppendHeader("Expires", DateTime.Now.AddDays(-1.0).ToString("r"));
                Response.AppendHeader("Pragma", "no-cache");
                Response.AppendHeader("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
                int state = (Request.QueryString["state"] == null) ? 0 : int.Parse(Request.QueryString["state"].ToString());
                SqlConnection conn = new SqlConnection(ConfigManager.ConnectionString);
                new UsersDao().ChangeState(conn, base.User.Identity.Name, state);
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
                UserCache.Update(base.User.Identity.Name);
            }
            catch (Exception exception)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("", exception);
                }
            }
        }

    }
}
